package com.digitalchina.lxnsy.viewholder;

import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.EvaluateVO;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.hedgehog.ratingbar.RatingBar;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2017/1/3 17:18
 * 修改备注：
 * ================================================
 */
public class GoodsEvaluateHolder extends BaseViewHolder<EvaluateVO> {

    private SimpleDraweeView sdvHead; // 头像
    private TextView tvName; // 用户名
    private TextView tvTime; // 时间
    private TextView tvContent; // 内容
    private RatingBar ratingBar; // 五角星


    public GoodsEvaluateHolder(ViewGroup parent) {
        super(parent, R.layout.item_evaluate_list);

        sdvHead = $(R.id.item_evaluate_sdv_head);
        tvName = $(R.id.item_evaluate_tv_name);
        tvTime = $(R.id.item_evaluate_tv_time);
        tvContent = $(R.id.item_evaluate_tv_content);
        ratingBar = $(R.id.rating_bar_describe);

    }

    @Override
    public void setData(EvaluateVO data) {
        super.setData(data);

        if (StringUtil.isStrEmpty(data.getImage()))
            FrescoUtil.showImageSmallForRes(R.drawable.bg_default_head, sdvHead);
        else
            FrescoUtil.showImageSmall(data.getImage(), sdvHead);

        if (data.isIsAnonymity())
            tvName.setText("匿名用户");
        else
            tvName.setText(data.getEvaluatePerson());
        tvTime.setText(data.getEvaluateTime());
        tvContent.setText(data.getContent());
        ratingBar.setStar(data.getScore());
    }

}
